import 'package:flutter/material.dart';
import 'package:flutter_app/widgets/commom_image.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

const List<String> _images = [
  'https://www.itying.com/images/flutter/1.png',
  'https://www.itying.com/images/flutter/2.png',
  'https://www.itying.com/images/flutter/3.png',
];

class SwiperCom extends StatelessWidget {
  const SwiperCom({Key? key, this.images = _images}) : super(key: key);
  final List<String> images;
  static const height = 424;
  static const width = 750;
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
            color: Colors.white,
            width: double.infinity,
            child: AspectRatio(
              aspectRatio: width / height,
              child: Swiper(
                key: ValueKey(images.length),
                itemBuilder: (BuildContext context, int index) {
                  return SizedBox(
                    height: 200,
                    child: CommonImage(src: images[index]),
                  );
                },
                itemCount: images.length,
                pagination: const SwiperPagination(),
                // control: const SwiperControl(),
                autoplay: true,
              ),
            ))
      ],
    );
  }
}
